package com.example.wechatdaka.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.wechatdaka.entity.UserWechat;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lx
 * @since 2020-11-29
 */
public interface UserWechatMapper extends BaseMapper<UserWechat> {
    @Select("select w.id,w.lxOpenid,u.lxUserNumber,u.lxUsername,c.lxClazzName \n" +
            "from lx_user_wechat w\n" +
            "left join lx_user u on w.lxUserId = u.id\n" +
            "left join lx_user_student s on s.lxUserId=u.id\n" +
            "left join lx_clazz c on c.id=s.lxClazzId\n" +
            "where w.lxOpenid=#{openId}")
    public UserWechat selectByOpenId(String openId);
    @Select("select w.id,w.lxOpenid,u.lxUserNumber,u.lxUsername,c.lxClazzName \n" +
            "from lx_user_wechat w\n" +
            "left join lx_user u on w.lxUserId = u.id\n" +
            "left join lx_user_student s on s.lxUserId=u.id\n" +
            "left join lx_clazz c on c.id=s.lxClazzId")
    public List<UserWechat> queryAllUserWechat();
    @Select("select w.id,w.lxOpenid,u.lxUserNumber,u.lxUsername,c.lxClazzName \n" +
            "from lx_user_wechat w\n" +
            "left join lx_user u on w.lxUserId = u.id\n" +
            "left join lx_user_student s on s.lxUserId=u.id\n" +
            "left join lx_clazz c on c.id=s.lxClazzId\n" +
            "where c.id=#{id}")
    public List<UserWechat> queryByClazz(String id);
    @Select("select w.id,w.lxOpenid,u.lxUserNumber,u.lxUsername,c.lxClazzName \n" +
            "from lx_user_wechat w\n" +
            "left join lx_user u on w.lxUserId = u.id\n" +
            "left join lx_user_student s on s.lxUserId=u.id\n" +
            "left join lx_clazz c on c.id=s.lxClazzId\n" +
            "where c.id=#{id}")
    public IPage<UserWechat> queryByClazzPage(Page page,String id);
    @Select("select w.id,w.lxOpenid,u.lxUserNumber,u.lxUsername,c.lxClazzName \n" +
            "from lx_user_wechat w\n" +
            "left join lx_user u on w.lxUserId = u.id\n" +
            "left join lx_user_student s on s.lxUserId=u.id\n" +
            "left join lx_clazz c on c.id=s.lxClazzId\n" +
            "where u.lxUserNumber=#{lxUserNumber}")
    public UserWechat queryByUserNumber(String lxUserNumber);
    @Select("select w.id,w.lxOpenid,u.lxUserNumber,u.lxUsername,c.lxClazzName \n" +
            "from lx_user_wechat w\n" +
            "left join lx_user u on w.lxUserId = u.id\n" +
            "left join lx_user_student s on s.lxUserId=u.id\n" +
            "left join lx_clazz c on c.id=s.lxClazzId")
    public IPage<UserWechat> queryAllUserWechatByPage(Page page);
}
